System and method to prioritize large memory page allocation in virtualized systems

ABSTRACT

The prioritization of large memory page mapping is a function of the access bits in the L1 page table. In a first phase of operation, the number of set access bits in each of the L1 page tables is counted periodically and a current count value is calculated therefrom. During the first phase, no pages are mapped large even if identified as such. After the first phase, the current count value is used to prioritize among potential large memory pages to determine which pages to map large. The system continues to calculate the current count value even after the first phase ends. When using hardware assist, the access bits in the nested page tables are used and when using software MMU, the access bits in the shadow page tables are used for large page prioritization.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a Continuation of U.S. patent application Ser. No.13/753,322, filed Jan. 29, 2013, which has issued as U.S. Pat. No.8,769,184; which is a Continuation of U.S. patent application Ser. No.12/915,236, filed Oct. 29, 2010, which has issued as U.S. Pat. No.8,364,932.

BACKGROUND OF THE INVENTION

In today's computers, as is well known to those of ordinary skill in theart, virtual memory decouples the address space of the running processesfrom the physical memory addresses. Virtual memory enables processes tohave a large contiguous address space that is not limited by anunderlying physical memory and allows the computer to run more processesthan can fit simultaneously in their entirety in the available physicalmemory, i.e., to allow for an “over-commit” of memory. To do this,virtual memory space is divided into pages of a fixed size, typically 4KB, with a size of 2 MB or greater being defined in this patent documentas a “large” page. Each page of the virtual memory space maps onto apage within the physical memory.

In general, and not meant to be a complete description of currenttechnology, an application accesses a virtual address (VA) that istranslated into a physical address (PA) that is then used to access thephysical memory. The translation produces what is called a linearaddress (LA). The LA is translated to the PA using hardware called aMemory Management Unit (MMU). If the system architecture does notsupport segmentation, then the LA is the same as the VA, and the VA isused by the MMU to translate to the PA.

As is well known, translation of a virtual memory address to a physicalmemory address is done by traversing page tables, located in RAM, thatcontain mapping information. To speed up the translation, a translationlookaside buffer (TLB) is typically used. The TLB provides a fastertranslation of virtual addresses to physical addresses than doesaccessing page tables in RAM because the TLB can provide thebeginning-to-end mapping in a single step and because the TLB can beimplemented in a small (and, therefore, fast to access) data structurecloser to, or in, the CPU. The TLB is limited in size, however, andoften a virtual memory page cannot be found in the TLB. Whenever thishappens, a “TLB miss” occurs, and the mapping has to be performed by atraversal of the page tables, commonly known as a “page walk,” a muchslower process when compared to look-ups in the TLB.

The following is meant as a general explanation for background purposesonly and may apply to a 64 bit architecture and a 4 KB page size as wellas a 32 bit architecture with different page sizes. A more detaileddiscussion of translation processes can be found in “Intel 64 and IA-32Architecture Application Note: TLBs, Paging-Structure Caches, and TheirInvalidation” available from Intel Corp. of Santa Clara, Calif., theentirety of which is incorporated by reference for all purposes.

Referring to FIG. 1, with respect to the common x86 architecture, a MMU100 consists of the following parts: a control register (CR3) 102, atranslation lookaside buffer (TLB) 104, and translation circuitry, i.e.,TLB fill hardware 106. The paging structures are: (a) 4 KB in size; (b)reside in main memory, generally separate from the MMU; and (c) aredesignated L4, L3, L2 and L1 page tables 108, 110, 112, 114,respectively. In some implementations, each of the page tables contains512 8-byte entries comprising information required to perform thetranslation as will be described below in more detail.

As shown in FIG. 2, the hardware register CR3 102 contains the baseaddress of the root page tables of the currently executing process. Infour-level paging (long mode) each level points to the next lower levelto, ultimately, determine the location of the backing memory page.

As is well known, an MMU 100 is typically equipped with one or more TLBs104, where the TLB 104 is a cache of recent LPN (Linear Page Number) toPPN (Physical Page Number) translations. To translate an LA, the MMU 100computes the LPN, and then looks in the TLB 104 for a translation of theLPN. If the translation is present in the TLB 104, referred to as a “TLBhit,” the PPN is immediately available from the TLB 104. On the otherhand, if the translation is not present in the TLB 104, referred to as a“TLB miss,” a page table walk is done, and the translation is stored inthe TLB, possibly evicting another entry from the TLB 104.

As shown in FIG. 3, a page table entry (PTE), e.g., PTE 201-n includesmultiple fields, or groups of bits, that represent: a physical pagenumber (PPN) 302, a page accessed bit (A) 304, a user permission bit (U)306, an execute permission bit (X) 308, a write permission (W) bit 310,a read permission (R) bit 312, a page dirty bit (D) 314, a page presentbit (P) 316, and a stop bit 318. When a linear address is used to accessmemory, the processor sets the A-bit 304 to one (1) in all page tablelevel entries used to translate the linear address. It should beunderstood that FIG. 3 illustrates one possible configuration of bits ina page table entry 201-n and that the number and arrangement of theelements in a page table entry 201-n can be varied from what is shown.

The PPN 302 indicates the next page in the page table hierarchy. If aparticular PTE 201-n is at the lowest level of the page table hierarchy,then the PPN 302 points to a data page. If a particular PTE 201-n is notat the lowest level of the page table hierarchy, then the PPN 302 pointsto a lower-level page table.

The stop bit 318 is set to one (1) to indicate that the correspondingPTE 201-n is at the lowest level of the page table hierarchy. As thesize of the data pages may vary within a physical memory, the stop bit318 may be set to one in PTEs 201-n at various levels in the page tablehierarchy. In this fashion, the page walk may be stopped so that one ormore levels in the page table hierarchy are not traversed when mapping alarge data page that is not in the TLB 104. At level L1 in the page treehierarchy, i.e., the lowest level that the page table hierarchysupports, the stop bit 318 is ignored.

As shown in FIG. 4, the virtual address 402 is subdivided into fivefields: a level four index 404, a level three index 406, a level twoindex 408, a level one index 410, and an offset 412. The virtual address402 may include additional bits or fields that are not used during themapping of virtual memory addresses to physical memory addresses. Eachof the index fields 404-410 and the offset field 412 may include anynumber of bits as may be appropriate for a given computer system.Typically, the subdivision of the virtual address 402 reflects thenumber of levels supported by the page walker or TLB fill hardware 106,the size of the smallest available physical pages, the size of thevirtual memory address space, and the size of the physical memoryaddress space.

In walking the page tables, the page table root CR3 102 is used todetermine that the L4 page table is the page table 108. The L4 index 404is used to index into the page table 108, thereby obtaining an L4 PTE.The PPN 302 stored in this L4 PTE is used to determine the L3 page table110. The L3 index 406 is used to index into the page table 110, therebyobtaining an L3 PTE. The PPN 302 stored in this L3 PTE is used todetermine the L2 page table 112. The L2 index 408 is used to index intothe L2 page table 112 thereby obtaining an L2 PTE. The PPN 302 stored inthis L2 PTE is used to determine the level one page table 114. The L1index 410 is used to index into the L1 page table 114, thereby obtainingan L1 PTE. The PPN 302 stored in this level one PTE is used to accessthe data page 204-n. Subsequently, the offset 412 is used to index intothe data page 204-n, thereby accessing the data corresponding to thevirtual address 410. In addition, the pair consisting of the virtualpage number corresponding to the index fields 404-410 and the physicalpage number corresponding to the data page 204-n is entered into the TLB104.

If the stop bit 318 is set in a PTE 201-n that is accessed at a higherlevel in the page table hierarchy, then the PPN 302 in the correspondingPTE 201-n is used to access a large data page. A system would then indexinto the large data page using a composition of the remaining index bitsof the virtual address 402 and the offset bits 412, thereby accessingthe data corresponding to the virtual address 402. In addition, thelarge page mapping is entered into the TLB 104.

As is well known, virtualizing a MMU so that multiple virtual machinescan run on a single hardware system typically entails another level oftranslation. The first translation is provided by a guest operatingsystem (guest OS) running in a virtual machine. The guest OS translatesa guest LPN (GLPN) into a corresponding guest PPN (GPPN) in theconventional manner. The second translation is provided byvirtualization software, for example, a virtual machine monitor (VMM).In particular, the VMM maintains a GPPN to machine page number (MPN)mapping in its internal translation table (T) where the host PPN is usedto address physical memory, i.e., the MPN. of the hardware system.

One of two methods is typically used for virtualizing an MMU, either ashadowing of guest paging structures (shadowing method), or a hardwareassist method. As shown in FIG. 5, the shadowing method for virtualizingan MMU, virtualization software, for example, a virtual machine monitorVMM, maintains shadow page tables 502, with one shadow page table foreach guest page table. While the guest page tables 504, maintained bythe guest operating system, contain guest LPN to guest PPN mappings, theshadow page tables contain guest LPN to host PPN mappings. To insert atranslation for a guest LPN into a shadow page table, the VMM walks theguest page table to determine the guest PPN. Then, it translates theguest PPN to a host PPN using its translation table T.

The architectural extensions introduced by AMD, with its Nested PageTables (NPT), and Intel, with its Extended Page Tables (EPT), areleveraged in the hardware assist method of virtualizing an MMU. Ageneral overview of hardware assist virtualization of an MMU can befound in the article “Accelerating Two-Dimensional Page Walks forVirtualized Systems,” by Bhargava, et al., ASPLOS'08, Mar. 1-5, 2008,Seattle, Wash., the entire contents of which is hereby incorporated byreference for all purposes.

Memory pages of a larger size, typically 2 MB in an x86 system, arecalled large pages or super pages. Large pages are supported by manygeneral purpose processors and allow each entry in the TLB to map alarge physical memory region into a virtual address space. Thisincreases the TLB reach, i.e., the amount of memory that can be accessedwithout causing a TLB fault, thereby decreasing the TLB misses, whichtranslates into performance increases for many applications.

One issue presents itself with the use of large pages—the problem ofdetermining which pages to map large, as large pages are a scarceresource. For a system with a VMM using shadow page tables or softwareMMU, the cost of figuring out which pages to map large should berelatively small in order to gain the maximum benefit. Currently, in ashadow MMU, i.e., a software MMU, large pages are assigned based on theorder in which the pages fault. The order of the faulting pages,however, does not necessarily indicate that a page is a good candidateto be backed by a large page.

Using large pages reduces the number of TLB misses and generallyimproves performance of virtual memory systems. The use of large pages,however, also generally reduces the ability of an operating system toefficiently utilize the physical memory. As large pages pose thisinherent tradeoff between fast memory access, and the accompanyingincrease in performance, and efficient utilization of physical memory,large pages are not typically used universally. Therefore, it isimportant to optimize their use and deploy them in a manner that willdeliver the biggest performance improvement. The optimization of the useof large memory pages is beneficial in both the shadowing of guestpaging structures (shadowing method) and the hardware assist method.

BRIEF SUMMARY OF THE INVENTION

In a computer system that utilized both guest page tables andcorresponding shadow page tables or hardware assist nested page tables,a method of selectively mapping shadow memory pages or nested pagetables as large includes determining whether a particular guest memorypage associated with the particular guest page table is mapped largeand, if so, whether a count which is indicative of the access fieldsthat are set within the shadow page tables or hardware assist nestedpage tables corresponding to the guest memory page exceeds a threshold.If the particular guest memory page is mapped large and the countexceeds the threshold, mapping a shadow page or nested page table aslarge within a shadow page table that corresponds to the particularguest page table.

In one embodiment, in a computer system having a virtual memory systemwith a plurality of page tables including a plurality of lowest level(L1) page tables, a method of prioritizing large memory page mappingincludes periodically calculating and storing a current count value,CCV[i], corresponding to a number, N_(sa), of currently set access bitsin each L1 page table. After a first time period has expired, and upondetection of a page fault corresponding to a faulted memory page, if thefaulted memory page is mapped large in a guest OS, then if a storedcurrent count value CCV[i] corresponding to the faulted memory page isgreater than a predetermined threshold value K, a corresponding shadowmemory page is mapped as large in a shadow page table structure ornested page tables.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

Various aspects of at least one embodiment of the present invention arediscussed below with reference to the accompanying figures. In thefigures, which are not intended to be drawn to scale, each identical ornearly identical component that is illustrated in the various figures isrepresented by a like numeral. For purposes of clarity, not everycomponent may be labeled in every drawing. The figures are provided forthe purposes of illustration and explanation and are not intended as adefinition of the limits of the invention. In the figures:

FIG. 1 is a block diagram of a known MMU and page table structure;

FIG. 2 is a representation of a multilevel page table structure;

FIG. 3 is a representation of the fields of a page table entry;

FIG. 4 is a representation of a virtual address being walked through apage table structure;

FIG. 5 is a block diagram of guest page tables and shadow page tables ina virtualized system;

FIGS. 6, 6A and 6B are flowcharts of a method in accordance with oneembodiment of the present invention;

FIGS. 7A and 7B are data structures used in embodiments of the presentinvention; and

FIG. 8 is a block diagram representation of a known virtualizationsystem.

DETAILED DESCRIPTION OF THE INVENTION

Excessive use of platform large pages can make memory resourcemanagement techniques such as page sharing, swapping, and the like,difficult and much less efficient. Thus, it is important to be selectivein choosing when and where to use platform large pages to gain the bestperformance/consolidation benefits.

Embodiments of the present invention propose using page table accessbits to prioritize among known guest large page candidates when mappingwith platform large pages in order to gain an improvedperformance/consolidation benefit.

Embodiments of the present invention implement heuristics/schemes thatare based on traversing shadow page tables or nested page tables to findthose L1 pages that can be remapped as a respective large page. Asabove, the heuristics are based on the access bits and the determinationas to whether or not to map a page large is a function of the number ofaccess bits that are set in an L1 page. Rather than mapping pages largein the order of faults, candidate L1 pages (2 MB) in the shadow pagetables or nested page tables are identified. The corresponding 512 pages(512 @4 KB) or PPNs, can then be mapped as a large page.

Thus, instead of providing large pages based on the order in which pagesfault, information is gathered from the shadow page tables or nestedpage tables and used to decide which pages to map large. Advantageously,embodiments of the present invention do not require changes to thestructure of the page table entries and/or the hardware as are currentlyknown and implemented.

Generally, and as an overview, embodiments of the present inventionimplement a two phase approach to determining whether or not to keeppages large. In the first phase, i.e., a “warm-up” phase, informationregarding a current number of set access bits is gathered periodicallyfrom each of the L1 page tables. It may be considered that the warm-upphase is used to “seed” the system with initial data. Subsequent to thewarm-up phase, a calculated count of the access bits in an L1 page tableis used to prioritize among the large pages to determine how to gain thebest performance/consolidation benefit. When using hardware assist, theaccess bits in the nested page tables are used and when using softwareMMU, the access bits in the shadow page tables are used for theprioritization algorithm. As will be described below, the current countnumber is continually periodically calculated.

As an overview, in one embodiment of the present invention, referringnow to FIG. 6, a method 540 begins, step 542, with a current count valueCCV being calculated and stored in a table, step 544. The calculation ofthe current count value CCV occurs periodically as will be described inmore detail below.

At the same time, step 546, when a page fault is detected, it is thendetermined, step 548, whether or not the warm-up period has expired orended, step 548. If the warm-up period has not expired, then controlpasses to step 550 where the page fault is processed but no large pagesare mapped, even if the faulting page is large.

If, on the other hand, the warm-up period has ended, then control passesto step 552 where the current count value, if there is one, for thefaulting page is used to determine whether or not to map a page large.

Referring now to FIG. 6A, step 544 includes clearing the A-bits of theL1 level page tables, step 602. Once the A-bits are cleared, apredetermined delay, in one embodiment about 10 seconds, is implemented,step 612. Once the delay period has ended, then a current count valueCCV[i] is determined as a function of the current total number of setA-bits in each of the L1 page tables, step 616.

The current count value CCV[i] is, in one embodiment of the presentinvention, determined every ten seconds over a warm-up period of about120 seconds. Generally, the warm-up period may be from 60-300 secondswith sampling at least 12 times during that period. The current countvalue CCV may be determined multiple times and computed using anexponential average method. One suitable formula for computing thecurrent count value CCV[i] is:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa)

-   -   Where α is a constant that satisfies the condition 0≦α≦1, and        where N_(sa) is the current number of set A-bits.

Thus, a current count value CCV[i] is based on a percentage (1−α) of theprior count value CCV[i−1] plus a percentage (a) of the current numberof set A-bits, N_(sa), in the L1 page.

In one example, with 512 L1 page table entries, the maximum number ofA-bits that can be set for a given L1 page table is, therefore, 512(i.e., N_(sa)≦512). To calculate the current count value CCV[i], thetotal number of A-bits that are set, N_(sa), out of the 512 L1 pagetable entries, is determined and then used in the formula to determinethe current count value CCV[i].

This current count value CCV[i] is stored, step 618, in a CCV table 700that has a structure, in one embodiment of the present invention, asshown in FIG. 7A. Thus, each time the current count value CCV[i] iscalculated, it is written over the previous value in the CCV table 700.

The CCV table 700 consists of a large page hashed address field 702 anda current count value field 704. Each entry 706, 708 has a large pagehashed address LHA and a corresponding current count value CCV[i]. Thehash is calculated over the large page region linear addresscorresponding to the L1 page table. When an appropriate hash function isused, every large page linear address should reduce to a unique hashvalue. This reduces the amount of memory space necessary to store theCCV table 700 and speeds up the searching of the table, as will bedescribed below.

Returning to the method 540, as shown in FIG. 6, generally, when a pagefault now occurs, the fault handler, once having determined that theguest linear address space region corresponding to the fault is mappedlarge, looks for an entry in the CCV table 700 corresponding to a hashof the guest linear address. This is represented by step 552.

A large memory page is then used in the shadow page tables for thelinear address region or guest physical address region in the nestedpage tables, if and only if:

1) a match is found for the large page address in the CCV table 700,

2) the corresponding current count value CCV[i] is greater than apre-determined threshold value K, where, in one embodiment, thethreshold value K is set to 320 and

3) the large memory page region does not contain candidate small pagesthat would be better used for other memory resource management featuressuch as, for example, but not limited to, page sharing, ballooning, andthe like.

In more detail for one embodiment of operations at process 552,referring now to FIG. 6B, at step 626 it is determined whether or notthe corresponding guest address space is mapped large. If the space isnot mapped large, then control passes to step 628 for normal processing,i.e., as known in the current state of the art. After which, controlpasses back to step 546 to wait for the next page fault to be detected.

If, at step 626, it is determined that it is a large guest address spacemapping, control passes to step 627 to determine if there is acorresponding entry in the CCV table 700. If no entry is found, based onthe hashed value of the address corresponding to the large guest addressspace, control passes to step 628.

On the other hand, a positive determination at step 627 passes controlto step 630, where the corresponding current count value CCV[i] isretrieved from the CCV table 700.

At step 632, the current count value CCV[i] is compared to thepredetermined threshold value K and if the current count value CCV[i] isnot greater than the threshold value K, control passes to step 628 fornormal processing, i.e., no large page mapping. Otherwise, controlpasses to step 634 where it is determined if the large memory page isstill a good candidate considering other memory resource managementfeatures that may be implemented over the proposed large memory page. Ifthe large memory page is not a good candidate, control passes to step628 for normal page mapping processing.

If the determination at step 634 is that the large page remains a goodcandidate, then control passes to step 636 for remapping of the smallpages in the shadow page tables of the VMM. It should be noted that theremapping of small pages to a large page is known to those of ordinaryskill in the art.

One embodiment of the present invention was implemented on a systemrunning with a software MMU but as detailed above, may also be used on asystem running with hardware MMU as well. In one embodiment of thepresent invention, the course of action the VMM takes when assigning alarge page on a page fault is changed from that which is known byidentifying large page candidates when the hypervisor incurs hidden pagefaults. Rather than immediately mapping shadow page tables with platformlarge pages, the large page region is included in the list of large pagecandidates. Once the warm-up phase, chosen to be 120 seconds, iscomplete, the determination of whether or not to map a page large iscarried out as set forth above. It should be noted that the duration ofthe warm-up phase and the frequency of calculating the current countvalue can be varied and tuned in accordance with desired operatingparameters.

In addition, embodiments of the present invention also provide for theVMM/monitor to map a large page at any time and it is not tied to anyevent in the guest. Whether the shadowing or the hardware assist methodis being used, because the VMM/monitor maintains separate structures,shadow page table pages in shadowing and a second level page table inhardware-assist, the VMM/monitor can map pages as small page or largepage irrespective of how they are mapped by the guest in its pagetables. Advantageously, the VMM/monitor can choose at any time to changethese mappings from small to large or vice versa in addition todetermining which pages to map as large.

Embodiments of the present invention may be implemented on the ESXserver available from VMware Corporation of Palo Alto, Calif.

It should be noted that in the above-described formula for determiningthe current count value CCV[i], choosing α=1 reduces the current countvalue to be equal to the number of A-bits in the L1 page table that areset without any weight given to the prior value CCV[i−1].

In addition, in the embodiment described above, only the most recentcount value CCV[i] is stored in the CCV table 700. In an alternateembodiment, not shown in the Figures, some number of the previous countvalues CCV[i−1], CCV[i−2] . . . CCV[i−n] may be stored in the table orother type of structure, depending upon the algorithm used to ultimatelydetermine the count parameter. Of course, more fields require morememory dedicated to this purpose. In addition, depending upon thecomputing resources available, an additional field could be provided inthe CCV table 700 to indicate if a corresponding entry is greater thanthe threshold value K, as shown in FIG. 7B. Thus, the determination atstep 632 could be replaced with an analysis of whether or not thisparticular field has been set, which may be a faster determination thanthe comparison shown in the embodiment above. One of ordinary skill inthe art will understand that other refinements are also possible.

The above detailed description of the various embodiments of theinvention assumed the reader's familiarity with virtualization;nevertheless, the following provides some background relating tovirtualization technology. It should be appreciated that one or moreembodiments of the present invention may be implemented wholly orpartially in hardware, for example and without limitation, in processorarchitectures intended to provide hardware support for VMs.

Although this specification describes translation processes for Intelprocessors, the details are similar for other popular x86 basedprocessors, and embodiments of the invention may be implemented on anyx86 or non-x86 based processor that supports virtual memory.

As is well known in the field of computer science, a virtual machine(VM) is an abstraction—a “virtualization”—of an actual physical computersystem. One possible arrangement of computer system 970 that implementsvirtualization is shown in FIG. 8. A virtual machine (VM) or “guest” 920is installed on a “host platform,” or simply “host,” which will includesystem hardware, that is, hardware platform 910, and one or more layersor co-resident components comprising system-level software, such as anoperating system or similar kernel, or a virtual machine monitor orhypervisor (see below), or some combination of these. The systemhardware typically includes one or more processors 911, memory 913, someform of mass storage 914, and various other devices 917.

Each VM 920, . . . , 920-n will typically have virtual system hardware928 and guest system software 929. The virtual system hardware includesat least one virtual CPU, virtual memory 923, an optional virtual disk924, and one or more virtual devices 927. Note that a disk virtual orphysical—is also a “device,” but is usually considered separatelybecause of the important role of the disk. All of the virtual hardwarecomponents of the VM may be implemented in software using knowntechniques to emulate the corresponding physical components. The guestsystem software includes guest operating system (OS) 922 and drivers 925as needed for the various virtual devices 927.

Note that a single VM may be configured with more than one virtualizedprocessor; as illustrated in FIG. 8, with multiple virtual processors921-0, 921-1, . . . , 921-m (VCPU0, VCPU1, . . . , VCPUm) within VM 920.For example, symmetric multi-processor (SMP) systems exist wherein ahardware platform with multiple processors are connected to a sharedmain memory and shared devices. Similarly, VMs may be configured as SMPVMs. In addition, multi-processor systems exist in a so-called“multi-core” architecture, wherein more than one physical CPU isfabricated on a single chip and has its own set of functional units(such as a floating-point unit and an arithmetic/logic unit ALU), andwhere threads can be executed independently; multi-core processorstypically share limited resources, such as some cache—VMs may beconfigured as multi-core systems. In addition, VMs may be configured toenable simultaneous execution of multiple threads in which more than onelogical CPU operates simultaneously on a single chip, but in which thelogical CPUs flexibly share one or more resources such as caches,buffers, functional units, and the like. One or more embodiments of thepresent invention may be used regardless of the type—physical and/orlogical—or number of processors included in a VM.

Some interface is generally required between the guest software within aVM and various hardware components and devices in the underlyinghardware platform. This interface—which may be referred to generally as“virtualization software”—may include one or more software componentsand/or layers, possibly including one or more of the software componentsknown as “virtual machine monitors” (VMMs), “hypervisors,” orvirtualization “kernels.” Because virtualization terminology has evolvedover time and has not yet become fully standardized, these terms do notalways provide clear distinctions between the software layers andcomponents to which they refer. For example, the term “hypervisor” isoften used to describe both a VMM and a kernel together, either asseparate but cooperating components or with one or more VMMsincorporated wholly or partially into the kernel itself; however, theterm “hypervisor” is sometimes used instead to mean some variant of aVMM alone, which interfaces with some other software layer(s) orcomponent(s) to support the virtualization. Moreover, in some systems,some virtualization code is included in at least one “superior” VM tofacilitate the operations of other VMs. Furthermore, specific softwaresupport for VMs may be included in a host OS itself; moreover, there mayalso be specific support for virtualization in the system hardware.Unless otherwise indicated, embodiments of the present invention may beused in virtualized computer systems having any type or configuration ofvirtualization software.

Virtual machine monitors 930, . . . , 930-n appear, as shown in FIG. 8,as separate entities from other components of the virtualizationsoftware. Some software components used to implement one illustratedembodiment of the invention are shown and described as being within a“virtualization layer” located logically between all virtual machinesand the underlying hardware platform and/or system-level host software.This virtualization layer can be considered part of the overallvirtualization software, although it would be possible to implement atleast part of this layer in specialized hardware. Unless otherwiseindicated, embodiments of the present invention may be used invirtualized computer systems having any type or configuration ofvirtualization software. Moreover, embodiments of the present inventionare described and illustrated herein primarily as including one or morevirtual machine monitors that appear as separate entities from othercomponents of the virtualization software and perform certain functionsrelating to one or more embodiments of the present invention. This isonly for the sake of simplicity and clarity of explanation and by way ofillustration—as mentioned above, the distinctions are not always soclear-cut, and the use of the term virtual machine monitor or just VMMis meant to encompass any component(s) in the virtualization softwarethat perform the described functions, regardless of what name they aregiven. Again, unless otherwise indicated or apparent from thedescription, it is to be assumed that embodiments of the presentinvention can be implemented anywhere within the overall structure ofthe virtualization software, and even in systems that provide specifichardware support for virtualization.

Various virtualized hardware components in the VM, such as the virtualCPU(s) VCPU0 921-0 to VCPUm 921-m, virtual memory 923, virtual disk 924,and virtual device(s) 927, are shown as being part of VM 920 for thesake of conceptual simplicity and ease of understanding. In actuality,these “components” are usually implemented as software emulations 933included in VMM1 930.

Different systems may implement virtualization to differentdegrees—“virtualization” generally relates to a spectrum of definitionsrather than to a bright line, and often reflects a design choice withrespect to a trade-off between speed and efficiency on the one hand andisolation and universality on the other hand. For example, “fullvirtualization” is sometimes used to denote a system in which nosoftware components of any form are included in the guest other thanthose that would be found in a non-virtualized computer; thus, the guestOS could be an off-the-shelf, commercially available OS with nocomponents included specifically to support use in a virtualizedenvironment.

In contrast, another concept, which has yet to achieve a universallyaccepted definition, is that of “para-virtualization.” As the nameimplies, a “para-virtualized” system is not “fully” virtualized, butrather the guest is configured in some way to provide certain featuresthat facilitate virtualization. For example, the guest in somepara-virtualized systems is designed to avoid hard-to-virtualizeoperations and configurations, such as by avoiding certain privilegedinstructions, certain memory address ranges, etc. As another example,many para-virtualized systems include an interface within the guest thatenables explicit calls to other components of the virtualizationsoftware.

For some, para-virtualization implies that the guest OS (in particular,its kernel) is specifically designed to support such an interface.According to this view, having, for example, an off-the-shelf version ofMicrosoft Windows XP as the guest OS would not be consistent with thenotion of para-virtualization. Others define para-virtualization morebroadly to include any guest OS with any code that is specificallyintended to provide information directly to any other component of thevirtualization software. According to this view, loading a module suchas a driver designed to communicate with other virtualization componentsrenders the system para-virtualized, even if the guest OS as such is anoff-the-shelf, commercially available OS not specifically designed tosupport a virtualized computer system. Unless otherwise indicated orapparent, this invention is not restricted to use in systems with anyparticular “degree” of virtualization and is not to be limited to anyparticular notion of full or partial (“para-”) virtualization.

In addition to the sometimes fuzzy distinction between full and partial(para-) virtualization, two arrangements of intermediate system-levelsoftware layer(s) are in general use—a “hosted” configuration and anon-hosted configuration (which is shown in FIG. 8). In a hostedvirtualized computer system, an existing, general-purpose operatingsystem forms a “host” OS that is used to perform certain input/output(I/O) operations, alongside and sometimes at the request of the VMM. Thehost OS, which usually includes drivers and supports applications of itsown, and the VMM are both able to directly access at least some of thesame hardware resources, with conflicts being avoided by acontext-switching mechanism. The Workstation product of VMware, Inc., ofPalo Alto, Calif., is an example of a hosted, virtualized computersystem, which is also explained in U.S. Pat. No. 6,496,847 (Bugnion, etal., “System and Method for Virtualizing Computer Systems,” 17 Dec.2002).

In addition to device emulators, other components are also oftenincluded in the VMM of a hosted virtualization system; many of thesecomponents are found in the VMM of a non-hosted system as well. Forexample, interrupt/exception handlers may be included to helpcontext-switching, and a direct execution engine and binary translatorwith associated a translation cache may be included to provide executionspeed while still preventing the VM from directly executing certainprivileged instructions.

The foregoing embodiments of the present invention may be implemented onone or more of the products available from VMware, Inc. of Palo Alto,Calif.

It is to be appreciated that embodiments of the methods and apparatusesdiscussed herein are not limited in application to the details ofconstruction and the arrangement of components or steps set forth in thefollowing description or illustrated in the accompanying drawings. Themethods and apparatuses are capable of implementation in otherembodiments and of being practiced or of being carried out in variousways. Examples of specific implementations are provided herein forillustrative purposes only and are not intended to be limiting. Inparticular, acts, elements and features discussed in connection with anyone of the embodiments are not intended to be excluded from a similarrole in any other embodiments. Also, the phraseology and terminologyused herein are for the purpose of description and should not beregarded as limiting. The use herein of “including,” “comprising,”“having,” “containing,” “involving,” and variations thereof, is meant toencompass the items listed thereafter and equivalents thereof as well asadditional items.

Embodiments of the above-described invention may be implemented in allsoftware, all hardware, or a combination of hardware and software,including program code stored in a firmware format to support dedicatedhardware. A software implementation of the above described embodiment(s)may comprise a series of computer instructions either fixed on atangible medium, such as a computer readable media, e.g., diskette,CD-ROM, ROM, or fixed disk or transmittable to a computer system in acarrier wave, via a modem or other interface device. The medium can beeither a tangible medium, including but not limited to optical or analogcommunications lines, or may be implemented with wireless techniques,including but not limited to radio, microwave, infrared or othertransmission techniques. The series of computer instructions whethercontained in a tangible medium or a carrier wave embodies all or part ofthe functionality previously described herein with respect to theinvention. Those skilled in the art will appreciate that such computerinstructions can be written in a number of programming languages for usewith many computer architectures or operating systems and may exist inmachine executable format. It is contemplated that such a computerprogram product may be distributed as a removable media withaccompanying printed or electronic documentation, e.g., shrink wrappedsoftware, preloaded with a computer system, e.g., on system ROM or fixeddisk, or distributed from a server over a network, e.g., the Internet orWorld Wide Web.

Although various exemplary embodiments of the present invention havebeen disclosed, it will be apparent to those skilled in the art thatchanges and modifications can be made which will achieve some of theadvantages of the invention without departing from the general conceptsof the invention. It will be apparent to those reasonably skilled in theart that other components performing the same functions may be suitablysubstituted. Further, the methods of the invention may be achieved ineither all software implementations, using the appropriate processorinstructions, or in hybrid implementations that utilize a combination ofhardware logic and software logic to achieve the same results. Suchalterations, modifications, and improvements are intended to be part ofthis disclosure and are intended to be within the scope of theinvention. Accordingly, the foregoing description and drawings are byway of example only, and the scope of the invention should be determinedfrom proper construction of the appended claims, and their equivalents.

What is claimed is:
 1. In a computer system having a virtual memorysystem that utilizes both a first set of guest page tables and a secondset of corresponding page tables, a method of selectively mapping memorypages as large comprising: during a translation of virtual memory pagesto physical memory pages, determining that a particular guest page tableis a lowest level guest page table, wherein the particular guest pagetable comprises a plurality of table entries in which each table entryincludes an access field that is set as a response to accessing a memoryaddress associated with the table entry; determining whether aparticular guest memory page associated with the particular guest pagetable is mapped large; determining whether a count which is indicativeof the access fields that are set within the particular guest page tableexceeds a threshold; and if the particular guest memory page is mappedlarge and the count exceeds the threshold, mapping a memory page aslarge within a corresponding page table within the second set of pagetables that corresponds to the particular guest page table.
 2. Themethod of claim 1 wherein the second set of page tables is a set ofnested page tables.
 3. In a computer system having a virtual memorysystem with a plurality of page tables including a plurality of lowestlevel (L1) page tables, a method of prioritizing large memory pagemapping comprising: periodically calculating and storing a current countvalue (CCV[i]) as a function of a number (N_(sa)) of currently setaccess bits in each L1 page table; and subsequent to a first timeperiod, and upon detection of a page fault corresponding to a faultedmemory page, and upon a determination that the faulted memory page ismapped large in a guest OS, then determining, as a function of a storedcurrent count value CCV[i] corresponding to the faulted memory page,whether or not to map a corresponding memory page as large in a nestedpage table structure.
 4. The method of claim 3, wherein the first timeperiod starts at a same time as a first periodic calculation of thecurrent count value CCV[i] begins.
 5. The method of claim 3, whereindetermining whether or not to map the corresponding memory page as largecomprises: retrieving a stored current count value CCV[i] correspondingto the faulted memory page; comparing the retrieved current count valueCCV[i] to a predetermined threshold value K; and if the retrievedcurrent count value CCV[i] is greater than the predetermined thresholdvalue K, mapping the corresponding memory page as large in the nestedpage table structure.
 6. The method of claim 5, further comprisingclearing the set access bits in the L1 page table after calculating thecorresponding current count value CCV[i].
 7. The method of claim 5,further comprising: mapping the corresponding memory page large onlyafter determining that the corresponding large memory page does notinterfere with memory page sharing.
 8. The method of claim 5, whereineach L1 page table consists of 512 page table entries, and wherein: thepredetermined threshold value K is at least
 320. 9. The method of claim3, wherein the current count value CCV[i] for a corresponding L1 pagetable is calculated as a function of a previously calculated count valueCCV[i−1] for the same L1 page table.
 10. The method of claim 9, whereinthe current count value CCV[i] is calculated according to the formula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 11. Themethod of claim 10, further comprising: setting at least one of α andthe predetermined threshold value K as a function of at least one of: anumber of page table entries in the L1 page table; and the other of αand the predetermined threshold value K.
 12. The method of claim 3,further comprising setting the first time period to be in a range of60-300 seconds.
 13. The method of claim 12, further comprising:periodically calculating and storing the current count value CCV[i] foreach L1 page table at least 10-12 times during the first time period.14. The method of claim 3, further comprising: storing the current countvalue CCV[i] with an identifier corresponding to the respective L1 pagetable.
 15. The method of claim 14, further comprising: calculating theidentifier of the corresponding L1 page table as a function of a virtualaddress.
 16. The method of claim 15, further comprising; calculating theidentifier of the corresponding L1 page table as a hash function appliedto a virtual address of a large memory page related to the correspondingL1 page table.
 17. The method of claim 3, further comprising: setting afirst value as a predetermined number of calculated count values CCV tobe obtained during the first time period; and spreading the calculationand storing of the predetermined number of calculated count values CCVfor each L1 page table over the first time period.
 18. In a virtualizedsystem running a guest operating system on hardware including a memorydevice, the virtualized system comprising a virtual machine monitor(VMM) maintaining a virtual memory system with a plurality of pagetables including a plurality of lowest level (L1) page tables, a methodof prioritizing large memory page mapping comprising: the VMMperiodically calculating and storing a current count value (CCV[i]) as afunction of a number (N_(sa)) of currently set access bits in each L1page table; and subsequent to a first time period, and upon detection ofa page fault corresponding to a faulted memory page, and upon adetermination that the faulted memory page is mapped large in a guestOS, the VMM then determining, as a function of a stored current countvalue CCV[i] corresponding to the faulted memory page, whether or not tomap a corresponding memory page as large in a nested page tablestructure.
 19. The method of claim 18, wherein the first time periodstarts at a same time as a first periodic calculation of the currentcount value CCV[i] begins.
 20. The method of claim 18, whereindetermining whether or not to map the corresponding memory page as largecomprises: the VMM retrieving a stored current count value CCV[i]corresponding to the faulted memory page; the VMM comparing theretrieved current count value CCV[i] to a predetermined threshold valueK; and if the retrieved current count value CCV[i] is greater than thepredetermined threshold value K, the VMM mapping the correspondingmemory page as large in the nested page table structure.
 21. The methodof claim 20, further comprising the VMM clearing the set access bits inthe L1 page table after calculating the corresponding current countvalue CCV[i].
 22. The method of claim 20, further comprising: the VMMmapping the corresponding memory page large only after determining thatthe corresponding large memory page does not interfere with memory pagesharing.
 23. The method of claim 20, wherein each L1 page table consistsof 512 page table entries, and wherein: the predetermined thresholdvalue K is at least
 320. 24. The method of claim 18, wherein the currentcount value CCV[i] for a corresponding L1 page table is calculated bythe VMM as a function of a previously calculated count value CCV[i−1]for the same L1 page table.
 25. The method of claim 24, wherein thecurrent count value CCV[i] is calculated by the VMM according to theformula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 26. Themethod of claim 25, further comprising: the VMM setting at least one ofα and the predetermined threshold value K as a function of at least oneof: a number of page table entries in the L1 page table; and the otherof α and the predetermined threshold value K.
 27. The method of claim18, further comprising: the VMM setting the first time period to be in arange of 60-300 seconds.
 28. The method of claim 27, further comprising:the VMM periodically calculating and storing the current count valueCCV[i] for each L1 page table at least 10-12 times during the first timeperiod.
 29. The method of claim 18, further comprising: the VMM storingthe current count value CCV[i] with an identifier corresponding to therespective L1 page table.
 30. The method of claim 29, furthercomprising: the VMM calculating the identifier of the corresponding L1page table as a function of a virtual address.
 31. The method of claim30, further comprising; the VMM calculating the identifier of thecorresponding L1 page table as a hash function applied to a virtualaddress of a large memory page related to the corresponding L1 pagetable.
 32. The method of claim 18, further comprising: the VMM setting afirst value as a predetermined number of calculated count values CCV tobe obtained during the first time period; and the VMM spreading thecalculation and storing of the predetermined number of calculated countvalues CCV for each L1 page table over the first time period.
 33. Acomputer program product stored on a non-transitory computer readablemedium and configured to perform a computer-implemented method ofprioritizing large memory page mapping in a system having a virtualmemory system with a plurality of page tables including a plurality oflowest level (L1) page tables, the method comprising: periodicallycalculating and storing a current count value CCV[i] as a function of anumber N_(sa) of currently set access bits in each L1 page table; andsubsequent to a first time period, and upon detection of a page faultcorresponding to a faulted memory page, and upon a determination thatthe faulted memory page is mapped large in a guest OS, then determining,as a function of a stored current count value CCV[i] corresponding tothe faulted memory page, whether or not to map a corresponding memorypage as large in a nested page table structure.
 34. The computer programproduct of claim 33, wherein the first time period starts at a same timeas a first periodic calculation of the current count value CCV[i]begins.
 35. The computer program product of claim 33, whereindetermining whether or not to map the corresponding memory page as largecomprises: retrieving a stored current count value CCV[i] correspondingto the faulted memory page; comparing the retrieved current count valueCCV[i] to a predetermined threshold value K; and if the retrievedcurrent count value CCV[i] is greater than the predetermined thresholdvalue K, mapping the corresponding memory page as large in the nestedpage table structure.
 36. The computer program product of claim 35,further comprising clearing the set access bits in the L1 page tableafter calculating the corresponding current count value CCV[i].
 37. Thecomputer program product of claim 35, further comprising: mapping thecorresponding memory page large only after determining that thecorresponding large memory page does not interfere with memory pagesharing.
 38. The computer program product of claim 35, wherein each L1page table consists of 512 page table entries, and wherein: thepredetermined threshold value K is at least
 320. 39. The computerprogram product of claim 33, wherein the current count value CCV[i] fora corresponding L1 page table is calculated as a function of apreviously calculated count value CCV[i−1] for the same L1 page table.40. The computer program product of claim 39, wherein the current countvalue CCV[i] is calculated according to the formula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 41. Thecomputer program product of claim 40, further comprising: setting atleast one of α and the predetermined threshold value K as a function ofat least one of: a number of page table entries in the L1 page table;and the other of α and the predetermined threshold value K.
 42. Thecomputer program product of claim 33, further comprising: setting thefirst time period to be in a range of 60-300 seconds.
 43. The computerprogram product of claim 42, further comprising: periodicallycalculating and storing the current count value CCV[i] for each L1 pagetable at least 10-12 times during the first time period.
 44. Thecomputer program product of claim 33, further comprising: storing thecurrent count value CCV[i] with an identifier corresponding to therespective L1 page table.
 45. The computer program product of claim 44,further comprising: calculating the identifier of the corresponding L1page table as a function of a virtual address.
 46. The computer programproduct of claim 45, further comprising; calculating the identifier ofthe corresponding L1 page table as a hash function applied to a virtualaddress of a large memory page related to the corresponding L1 pagetable.
 47. The computer program product of claim 33, further comprising:setting a first value as a predetermined number of calculated countvalues CCV to be obtained during the first time period; and spreadingthe calculation and storing of the predetermined number of calculatedcount values CCV for each L1 page table over the first time period. 48.A computer system including a storage device storing computerinstructions configured to perform a computer-implemented method ofprioritizing large memory page mapping in a virtualized system havingone or more central processing units for executing the computerinstructions and having a virtual memory system with a plurality of pagetables including a plurality of lowest level (L1) page tables, themethod comprising: periodically calculating and storing a current countvalue CCV[i] as a function of a number N_(sa) of currently set accessbits in each L1 page table; and subsequent to a first time period, andupon detection of a page fault corresponding to a faulted memory page,and upon a determination that the faulted memory page is mapped large ina guest OS, then determining, as a function of a stored current countvalue CCV[i] corresponding to the faulted memory page, whether or not tomap a corresponding memory page as large in a nested page tablestructure.
 49. The computer system of claim 48, wherein the first timeperiod starts at a same time as a first periodic calculation of thecurrent count value CCV[i] begins.
 50. The computer system of claim 48,wherein determining whether or not to map the corresponding memory pageas large comprises: retrieving a stored current count value CCV[i]corresponding to the faulted memory page; comparing the retrievedcurrent count value CCV[i] to a predetermined threshold value K; and ifthe retrieved current count value CCV[i] is greater than thepredetermined threshold value K, mapping the corresponding memory pageas large in the nested page table structure.
 51. The computer system ofclaim 50, the method further comprising clearing the set access bits inthe L1 page table after calculating the corresponding current countvalue CCV[i].
 52. The computer system of claim 50, the method furthercomprising: mapping the corresponding memory page large only afterdetermining that the corresponding large memory page does not interferewith memory page sharing.
 53. The computer system of claim 50, whereineach L1 page table consists of 512 page table entries, and wherein: thepredetermined threshold value K is at least
 320. 54. The computer systemof claim 48, wherein the current count value CCV[i] for a correspondingL1 page table is calculated as a function of a previously calculatedcount value CCV[i−1] for the same L1 page table.
 55. The computer systemof claim 54, wherein the current count value CCV[i] is calculatedaccording to the formula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 56. Thecomputer system of claim 55, the method further comprising: setting atleast one of α and the predetermined threshold value K as a function ofat least one of: a number of page table entries in the L1 page table;and the other of α and the predetermined threshold value K.
 57. Thecomputer system of claim 48, the method further comprising: setting thefirst time period to be in a range of 60-300 seconds.
 58. The computersystem of claim 57, the method further comprising: periodicallycalculating and storing the current count value CCV[i] for each L1 pagetable at least 10-12 times during the first time period.
 59. Thecomputer system of claim 48, the method further comprising: storing thecurrent count value CCV[i] with an identifier corresponding to therespective L1 page table.
 60. The computer system of claim 59, themethod further comprising: calculating the identifier of thecorresponding L1 page table as a function of a virtual address.
 61. Thecomputer system of claim 60, the method further comprising; calculatingthe identifier of the corresponding L1 page table as a hash functionapplied to a virtual address of a large memory page related to thecorresponding L1 page table.
 62. The computer system of claim 48, themethod further comprising: setting a first value as a predeterminednumber of calculated count values CCV to be obtained during the firsttime period; and spreading the calculation and storing of thepredetermined number of calculated count values CCV for each L1 pagetable over the first time period.
 63. In a virtualized system running aguest operating system on hardware including a memory device, thevirtualized system comprising a virtual machine monitor (VMM)maintaining a virtual memory system with a plurality of nested pagetables including a plurality of lowest level (L1) nested page tables, amethod of prioritizing large memory page mapping comprising: the VMMperiodically calculating and storing a current count value CCV[i] as afunction of a number N_(sa) of currently set access bits in each L1nested page table; and subsequent to a first time period, the VMM thendetermining, as a function of a stored current count value CCV[i]corresponding to a respective memory page, whether or not to map therespective memory page as large in the nested page tables.
 64. Themethod of claim 63, wherein the first time period starts at a same timeas a first periodic calculation of the current count value CCV[i]begins.
 65. The method of claim 63, wherein determining whether or notto map the respective memory page as large comprises: the VMM retrievinga stored current count value CCV[i] corresponding to the respectivememory page; the VMM comparing the retrieved current count value CCV[i]to a predetermined threshold value K; and if the retrieved current countvalue CCV[i] is greater than the predetermined threshold value K, theVMM mapping the corresponding memory page as large in the nested pagetable structure.
 66. The method of claim 65, further comprising the VMMclearing the set access bits in the L1 page table after calculating thecorresponding current count value CCV[i].
 67. The method of claim 65,wherein each L1 page table consists of 512 page table entries, andwherein: the predetermined threshold value K is at least
 320. 68. Themethod of claim 63, wherein the current count value CCV[i] for acorresponding L1 page table is calculated by the VMM as a function of apreviously calculated count value CCV[i−1] for the same L1 page table.69. The method of claim 68, wherein the current count value CCV[i] iscalculated by the VMM according to the formula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 70. Themethod of 69, further comprising: the VMM setting at least one of α andthe predetermined threshold value K as a function of at least one of: anumber of page table entries in the L1 page table; and the other of αand the predetermined threshold value K.
 71. The method of claim 63,further comprising: the VMM setting the first time period to be in arange of 60-300 seconds.
 72. The method of claim 71, further comprising:the VMM periodically calculating and storing the current count valueCCV[i] for each L1 page table at least 10-12 times during the first timeperiod.
 73. The method of claim 63, further comprising: the VMM settinga first value as a predetermined number of calculated count values CCVto be obtained during the first time period; and the VMM spreading thecalculation and storing of the predetermined number of calculated countvalues CCV for each L1 page table over the first time period.
 74. Acomputer program product stored on a non-transitory computer readablemedium and configured to perform a computer-implemented method ofselectively mapping memory pages as large in a system having a virtualmemory system that utilizes both guest page tables and correspondingnested page tables, the method comprising: during a translation ofvirtual memory pages to physical memory pages, determining that aparticular guest page table is a lowest level guest page table, whereinthe particular guest page table comprises a plurality of table entriesin which each table entry includes an access field that is set as aresponse to accessing a memory address associated with the table entry;determining whether a particular guest memory page associated with theparticular guest page table is mapped large; determining whether a countwhich is indicative of the access fields that are set within theparticular guest page table exceeds a threshold; and if the particularguest memory page is mapped large and the count exceeds the threshold,mapping a memory page as large within a nested page table thatcorresponds to the particular guest page table.
 75. The computer programproduct of claim 74 wherein determining the count includes calculating acount value for a selected period of time.
 76. A computer programproduct stored on a non-transitory computer readable medium andconfigured to perform a computer-implemented method of prioritizinglarge memory page mapping in a virtualized system running a guestoperating system on hardware including a memory device, the virtualizedsystem comprising a virtual machine monitor (VMM) maintaining a virtualmemory system with a plurality of page tables including a plurality oflowest level (L1) page tables, the method comprising: the VMMperiodically calculating and storing a current count value (CCV[i]) as afunction of a number (N_(sa)) of currently set access bits in each L1page table; and subsequent to a first time period, and upon detection ofa page fault corresponding to a faulted memory page, and upon adetermination that the faulted memory page is mapped large in a guestOS, the VMM then determining, as a function of a stored current countvalue CCV[i] corresponding to the faulted memory page, whether or not tomap a corresponding memory page as large in a nested page tablestructure.
 77. The computer program product of claim 76, wherein thefirst time period starts at a same time as a first periodic calculationof the current count value CCV[i] begins.
 78. The computer programproduct of claim 76, wherein determining whether or not to map thecorresponding memory page as large comprises: the VMM retrieving astored current count value CCV[i] corresponding to the faulted memorypage; the VMM comparing the retrieved current count value CCV[i] to apredetermined threshold value K; and if the retrieved current countvalue CCV[i] is greater than the predetermined threshold value K, theVMM mapping the corresponding memory page as large in the nested pagetable structure.
 79. The computer program product of claim 78, furthercomprising the VMM clearing the set access bits in the L1 page tableafter calculating the corresponding current count value CCV[i].
 80. Thecomputer program product of claim 78, further comprising: the VMMmapping the corresponding memory page large only after determining thatthe corresponding large memory page does not interfere with memory pagesharing.
 81. The computer program product of claim 78, wherein each L1page table consists of 512 page table entries, and wherein: thepredetermined threshold value K is at least
 320. 82. The computerprogram product of claim 76, wherein the current count value CCV[i] fora corresponding L1 page table is calculated by the VMM as a function ofa previously calculated count value CCV[i−1] for the same L1 page table.83. The computer program product of claim 82, wherein the current countvalue CCV[i] is calculated by the VMM according to the formula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 84. Thecomputer program product of claim 83, further comprising: the VMMsetting at least one of α and the predetermined threshold value K as afunction of at least one of: a number of page table entries in the L1page table; and the other of α and the predetermined threshold value K.85. The computer program product of claim 76, further comprising: theVMM setting the first time period to be in a range of 60-300 seconds.86. The computer program product of claim 85, further comprising: theVMM periodically calculating and storing the current count value CCV[i]for each L1 page table at least 10-12 times during the first timeperiod.
 87. The computer program product of claim 76, furthercomprising: the VMM storing the current count value CCV[i] with anidentifier corresponding to the respective L1 page table.
 88. Thecomputer program product of claim 87, further comprising: the VMMcalculating the identifier of the corresponding L1 page table as afunction of a virtual address.
 89. The computer program product of claim88, further comprising; the VMM calculating the identifier of thecorresponding L1 page table as a hash function applied to a virtualaddress of a large memory page related to the corresponding L1 pagetable.
 90. The computer program product of claim 76, further comprising:the VMM setting a first value as a predetermined number of calculatedcount values CCV to be obtained during the first time period; and theVMM spreading the calculation and storing of the predetermined number ofcalculated count values CCV for each L1 page table over the first timeperiod.
 91. A computer program product stored on a non-transitorycomputer readable medium and configured to perform acomputer-implemented method of prioritizing large memory page mapping ina virtualized system running a guest operating system on hardwareincluding a memory device, the virtualized system comprising a virtualmachine monitor (VMM) maintaining a virtual memory system with aplurality of nested page tables including a plurality of lowest level(L1) nested page tables, the method comprising: the VMM periodicallycalculating and storing a current count value CCV[i] as a function of anumber N_(sa) of currently set access bits in each L1 nested page table;and subsequent to a first time period, the VMM then determining, as afunction of a stored current count value CCV[i] corresponding to arespective memory page, whether or not to map the respective memory pageas large in the nested page tables.
 92. The computer program product ofclaim 91, wherein the first time period starts at a same time as a firstperiodic calculation of the current count value CCV[i] begins.
 93. Thecomputer program product of claim 91, wherein determining whether or notto map the respective memory page as large comprises: the VMM retrievinga stored current count value CCV[i] corresponding to the respectivememory page; the VMM comparing the retrieved current count value CCV[i]to a predetermined threshold value K; and if the retrieved current countvalue CCV[i] is greater than the predetermined threshold value K, theVMM mapping the corresponding memory page as large in the nested pagetable structure.
 94. The computer program product of claim 93, furthercomprising the VMM clearing the set access bits in the L1 page tableafter calculating the corresponding current count value CCV[i].
 95. Thecomputer program product of claim 93, wherein each L1 page tableconsists of 512 page table entries, and wherein: the predeterminedthreshold value K is at least
 320. 96. The computer program product ofclaim 91, wherein the current count value CCV[i] for a corresponding L1page table is calculated by the VMM as a function of a previouslycalculated count value CCV[i−1] for the same L1 page table.
 97. Thecomputer program product of claim 96, wherein the current count valueCCV[i] is calculated by the VMM according to the formula:CCV[i]=(1−α)*CCV[i−1]+α*N _(sa), where 0≦α≦1; and where CCV[i−1] is animmediately previous value of the current count value CCV.
 98. Thecomputer program product of 97, further comprising: the VMM setting atleast one of α and the predetermined threshold value K as a function ofat least one of: a number of page table entries in the L1 page table;and the other of α and the predetermined threshold value K.
 99. Thecomputer program product of claim 91, further comprising: the VMMsetting the first time period to be in a range of 60-300 seconds. 100.The computer program product of claim 99, further comprising: the VMMperiodically calculating and storing the current count value CCV[i] foreach L1 page table at least 10-12 times during the first time period.101. The computer program product of claim 91, further comprising: theVMM setting a first value as a predetermined number of calculated countvalues CCV to be obtained during the first time period; and the VMMspreading the calculation and storing of the predetermined number ofcalculated count values CCV for each L1 page table over the first timeperiod.